package com.xca.znb.presenter;

import com.xca.znb.entity.Goods;
import com.xca.znb.entity.Local;
import com.xca.znb.entity.NewsLetter;
import com.xca.znb.entity.Order;
import com.xca.znb.entity.User;
import com.xca.znb.model.imodel.IOrderMessage;

public class OrderMessagePresenter {
    private IOrderMessage iOrderMessage ;
    public OrderMessagePresenter(IOrderMessage iOrderMessage){
        this.iOrderMessage = iOrderMessage ;
    }

    public Local getLocalById(int id) {
        return iOrderMessage.getLocalById(id);
    }

    public User getUserByPhone(String phone) {
        return iOrderMessage.getUserByPhone(phone);
    }

    public Goods getGoodsById(int id) {
        return iOrderMessage.getGoodsById(id);
    }

    public Order getOrderById(int id) {
        return iOrderMessage.getOrderById(id);
    }

    public void addNewsletter(String phone1, String phone2, String time) {
        NewsLetter newsLetter = iOrderMessage.getNewsLetterByPhone(phone1, phone2);
        NewsLetter newsLetter1 = iOrderMessage.getNewsLetterByPhone(phone2 , phone1);
        if (newsLetter == null && newsLetter1 == null){
            iOrderMessage.addNewsletter(phone1, phone2, time);
        }
    }

    public void updateOrderType(int id, String type, String time) {
        iOrderMessage.updateOrderType(id, type, time);
    }

    public void insertAccount(String phone, double num, String type, String time_day, String time_sec) {
        iOrderMessage.insertAccount(phone, num, type, time_day, time_sec);
    }
}
